//
//  FLNLoginRegisterField.m
//  百思不得姐
//
//  Created by xmg on 16/6/10.
//  Copyright © 2016年 FLN.com. All rights reserved.
//

#import "FLNLoginRegisterField.h"

@implementation FLNLoginRegisterField

- (void)awakeFromNib {

    //1.设置文本框光标
    self.tintColor = [UIColor whiteColor];
    
    //2.监听文本框什么时候开始编辑
    [self addTarget:self action:@selector(textBegin) forControlEvents:UIControlEventEditingDidBegin];
    //监听结束编辑
    [self addTarget:self action:@selector(textEnd) forControlEvents:UIControlEventEditingDidEnd];
    
    //优化代码
    [self setPlaceholderColor:[UIColor lightGrayColor]];
}

- (void)setPlaceholderColor:(UIColor *)placeholderColor {
    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
    attr[NSForegroundColorAttributeName] = placeholderColor;
    self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder attributes:attr];

}

- (void)textBegin {

    [self setPlaceholderColor:[UIColor whiteColor]];

}

- (void)textEnd {

    [self setPlaceholderColor:[UIColor lightGrayColor]];
}

@end
